package com.example;


import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class ProductDAO {

    private String sql;

    List<Product> getProducts() {
        List<Product> productList = new ArrayList< Product>();
        String query = "SELECT * FROM products";
        try {
            ResultSet rs = JdbcUtils.executeQuery(sql);
            while (rs.next()) {
                Product product = new Product();
                rs.getInt("id");
                rs.getString("name");
                rs.getString("description");
                rs.getDouble("price");
                productList.add(product);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return productList;
    }
}